package com.bringway.global.util.excel;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WriteException;

/**
 * <p>Title: com.ziwu.util.ExcelFormat.java</p>
 * <p>Description: Excel格式定义</p>
 * <p>Date: 2010-7-22 </p>
 * @author xuezheng
 * @version 0.1
 */
public class ExcelFormat {
	
	/** 得到标题格式 */
	public static WritableCellFormat getTitleFormat() throws WriteException{
		WritableFont fntTitle = 
			new WritableFont(WritableFont.ARIAL,14,WritableFont.BOLD);
		WritableCellFormat titleFormat = new WritableCellFormat(fntTitle);
		titleFormat.setAlignment(Alignment.CENTRE);
		titleFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
		return titleFormat;
	}
	
	/** 得到内容格式 */
	public static WritableCellFormat getContentFormat() throws WriteException{
		WritableFont font = new WritableFont(WritableFont.TAHOMA, 10);
		WritableCellFormat contentFormat = new WritableCellFormat(font);
		contentFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
		return contentFormat;
	}
	
	/** 得到标签格式 */
	public static WritableCellFormat getSmallTitleFormat() throws WriteException{
		WritableFont font = new WritableFont(WritableFont.TAHOMA, 10,WritableFont.BOLD);
		WritableCellFormat contentFormat = new WritableCellFormat(font);
		contentFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
		return contentFormat;
	}
	
	/** 批量添加单元格 */
	public static void addCells(WritableSheet sheet, Label[] labels) throws Exception {
		for(Object label : labels) {
			sheet.addCell((Label)label);
		}
	}
	
	public static void addNumCells(WritableSheet sheet, jxl.write.Number[] nums) throws Exception {
		for(Object num : nums) {
			sheet.addCell((jxl.write.Number)num);
		}
	}
}
